import { Injectable } from '@nestjs/common';
import { Logger } from '../common/logger/logger';

@Injectable()
export class SymbolDemoService {
	constructor(
   
  ) {}
  async testDemo(): Promise<string> {
		// return await this.test1()
		// return await this.test2()
		return await this.test3()
  }
	async test1(): Promise<string>{
		let x = Symbol('abc')
		let y = Symbol('123')
		Logger.info(x, y)  // Symbol(abc) Symbol(123)
		return ""
	}

	async test2(): Promise<string>{
		//tostring方法
		let s = Symbol("脚本之家");
		// console.log(s+"欢迎您");  不能使用 +号
		console.log(s.toString()+"欢迎您"); //out： Symbol(脚本之家)欢迎您
		return ""
	}

	async test3(): Promise<string>{
		let s = Symbol.for("脚本之家");
		console.log(Symbol.keyFor(s));  // out：脚本之家
		return ""
	}
}

